using UnityEngine;

public class JCAchievementMunger : MonoBehaviour
{
	public static void CheckProgress()
	{
		if (PlayerPrefs.GetInt("Wins") > 0)
		{
			UnlockAchievement("CgkI3_DHnsgeEAIQBQ");
		}
		if (PlayerPrefs.GetInt("Matches Played") > 0)
		{
			UnlockAchievement("CgkI3_DHnsgeEAIQAw");
		}
		if (PlayerPrefs.GetInt("Matches Played") >= 100)
		{
			UnlockAchievement("CgkI3_DHnsgeEAIQBA");
		}
		if (PlayerPrefs.GetInt("Wins") >= 365)
		{
			UnlockAchievement("CgkI3_DHnsgeEAIQBg");
		}
		if (PlayerPrefs.GetInt("Stopped") >= 300)
		{
			UnlockAchievement("CgkI3_DHnsgeEAIQEA");
		}
	}

	public static void UnlockAchievement(string id)
	{
		Social.ReportProgress(id, 100.0, delegate(bool success)
		{
			Log(success);
		});
	}

	public static void IncrementAchievement(string id, double progress)
	{
		if (Social.localUser.authenticated)
		{
			Social.ReportProgress(id, progress * 100.0, delegate(bool success)
			{
				Log(success);
			});
		}
	}

	public static void ActivateGooglePlay()
	{
		Social.localUser.Authenticate(delegate(bool success)
		{
			if (!success)
			{
				UnityEngine.Debug.LogWarning("Failed to log in to Google Play Games");
			}
		});
	}

	private static void Log(bool success)
	{
		if (!success)
		{
			UnityEngine.Debug.LogError("Failed to unlock achievement");
		}
	}
}
